<!-- <!DOCTYPE html> -->
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<!-- 使用UTF-8 -->
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<!-- 设置移动终端可视区域 -->
		<meta content="telephone=no" name="format-detection">
		<!-- 禁止iPhone等手机自动将数字变成可点击的拨号连接 -->
		<title>966588服务</title>
		<link href="css/style.css" type="text/css" rel="stylesheet" />
		<link href="css/weui.css" type="text/css" rel="stylesheet" />
	</head>
	<body style="background: #F6F6F6;">
		<div class="index" id="containerVue" v-cloak>
			<!-- 统计数量弹出层 -->
			<div class="statisticsTip">
				<div v-show="showBanner" class="headerView">
					<i @click="backView">&lsaquo;</i>
					<h1>"966588"查询系统</h1>
					<div></div>
				</div>
				<!-- loading 加载 -->
				<div style="opacity: 1;" v-if="loading">
					<div class="weui-mask_transparent"></div>
					<div class="weui-toast">
						<img src="image/load.gif" alt="" style="width: 2rem;margin: 2rem auto .5rem;">
						<p class="weui-toast__content">加载中</p>
					</div>
				</div>
				<div class="statisticsView">
					<div class="statistics clearfix statisticsTwo" v-if="roleComplaint">
						<div style="width: 100%;">
							<div class="list" @click="goIndex">
								<img src="image/xmzs.png" alt="" class="icon">
								<div class="text">项目列表</div>
								<div class="num">{{statisticsInfo.duringProjectNum}}/{{statisticsInfo.totalProjectNum}} <span style="font-size: .7rem;">条</span></div>
							</div>
							<div class="list" @click="taskAll">
								<img src="image/wcdd.png" alt="" class="icon">
								<div class="text">调整记录</div>
								<div class="num">{{statisticsInfo.haveAdjustedNum}}/{{statisticsInfo.adjustNum}} <span style="font-size: .7rem;">条</span></div>
							</div>
							<div class="list" @click="evalAll">
								<img src="image/pjzs.png" alt="" class="icon">
								<div class="text">评价记录</div>
								<div class="num">{{statisticsInfo.evaluationNum}} <span style="font-size: .7rem;">条</span></div>
							</div>
							<div class="list" @click="compAll">
								<img src="image/tszs.png" alt="" class="icon">
								<div class="text">投诉记录</div>
								<div class="num">{{statisticsInfo.haveComplaintNum}}/{{statisticsInfo.complaintNum}} <span style="font-size: .7rem;">条</span></div>
							</div>
							<div class="list" @click="goStatistics" style="width: 100%;" v-if="roleCode == 'LeaderRole'">
								<img src="image/xmtj.png" alt="" class="icon">
								<div class="text">项目统计</div>
							</div>
						</div>
						<!-- <div class="statistics_btn" @click="goIndex">返回列表</div> -->
						<!-- <img src="image/closeW.png" alt="" class="statisticsClose" @click="statisticsClose"> -->
					</div>
					<div class="statistics clearfix" v-else>
						<div style="width: 100%;">
							<div class="list" @click="goIndex" style="width: 100%;">
								<img src="image/xmzs.png" alt="" class="icon">
								<div class="text">项目列表</div>
								<div class="num">{{statisticsInfo.duringProjectNum}}/{{statisticsInfo.totalProjectNum}} <span style="font-size: .7rem;">条</span></div>
							</div>
							<div class="list" @click="taskAll">
								<img src="image/wcdd.png" alt="" class="icon">
								<div class="text">调整记录</div>
								<div class="num">{{statisticsInfo.haveAdjustedNum}}/{{statisticsInfo.adjustNum}} <span style="font-size: .7rem;">条</span></div>
							</div>
							<div class="list" @click="evalAll">
								<img src="image/pjzs.png" alt="" class="icon">
								<div class="text">评价记录</div>
								<div class="num">{{statisticsInfo.evaluationNum}} <span style="font-size: .7rem;">条</span></div>
							</div>
							<div class="list" @click="goStatistics" style="width: 100%;" v-if="roleCode == 'LeaderRole'||roleCode=='TeamLeader'||roleCode=='DepartLeaderRole'">
								<img src="image/xmtj.png" alt="" class="icon">
								<div class="text">项目统计</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<script src="script/jquery-3.5.js"></script>
		<script src="script/vue.js"></script>
		<script src="script/api.js"></script>
		<script src="script/ajax.js"></script>
		<!-- <script src="script/iscroll.js"></script> -->
		<!-- <script src="../js/common/mui.min.js"></script> -->
		<!-- <script src="../js/common/openview.js"></script> -->
		<script>
			var mScroll;
			var isRefresh = false;
			var app = new Vue({
				el: '#containerVue',
				data: {
					param: {
						contractId: '',
						isDealed: '-1',
						keyWord: '',
						pageNo: 1,
						pageSize: 10
					}, // 搜索条件

					isEnd: false,
					isAjax: false,
					loading: false,
					roleCode: "", // 角色类型
					scanInfo: null, // 扫描信息
					statistics: false, // 统计层
					statisticsInfo: {}, // 统计信息
					roleComplaint: false, // 投诉权限
					roleAdjust: false,
          showBanner:true,
				},
				created() {
					this.getLogin();
				},
				watch: {

				},
				methods: {
				  autoLogin(username){
            let param={},_this=this;
            _this.showBanner=false;
            localStorage.setItem("showBanner",_this.showBanner?1:0);
            loginHttp({
              url: 'jeecg-boot/sys/ssologin',
              type: 'post',
              data: {
                'userName': username
              },
              success: function(res) {
                // console.log(res);
                // 本地存入token
                if (res.success) {
                  localStorage.setItem('access_token', res.result['token']);
                  localStorage.setItem('userName', res.result.userInfo.username);
                  localStorage.setItem('passWord', res.result.userInfo.password);
                  _this.getRole();
                  //window.location.href = "./survey_inside/statistics.html";
                } else {
                  $.Jwarning(res.message);
                  setTimeout(function() {
                    window.location.href = "../login.html";
                  }, 3000)
                }
              }
            })
          },
          GetQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]);
            return null;
          },
					backView() {
						window.location.href = "../login.html";
					},
					goIndex() {
						if (this.roleCode == "LeaderRole") {
							window.location.href = 'index_census.html';
						} else {
							window.location.href = 'index.html';
						}
					},
					// 项目统计查看
					goStatistics() {
						window.location.href = './statistics2.html';
					},
					// 任务调整总数查看
					taskAll() {
						window.location.href = 'taskAllList.html';
					},
					// 评价总数查看
					compAll() {
						window.location.href = 'complaintAllList.html';
					},
					// 评价总数查看
					evalAll() {
						window.location.href = 'evalAllList.html';
					},
					// 获取统计信息
					getStatistics() {
						var that = this;
						ajaxHttp({
							url: 'jeecg-boot/node/nodeContract/getAllTotalInfos',
							type: 'post',
							data: {},
							beforeSend: function() {
								that.loading = true
							},
							success: function(res) {
								console.log(JSON.stringify(res));
								if (res.success) {
									that.statisticsInfo = res.result
								} else {
									$.Jwarning(res.message)
								}
							},
							complete: function() {
								that.loading = false
							},
							error: function(err) {
								console.log(err);
							}
						});
					},
					// 判断是否走登录页面
					getLogin() {
						let userName = $.Request('userName'),autoUsername=decodeURI(decodeURI(this.GetQueryString("username")));
						let that = this;
						if(autoUsername=='null'){
						  that.showBanner=true;
              localStorage.setItem("showBanner",that.showBanner?1:0);
              if (userName == 'null') {
                that.getRole();
              } else {
                loginHttp({
                  url: 'jeecg-boot/sys/ssologin',
                  type: 'post',
                  data: {
                    'userName': userName
                  },
                  success: function(res) {
                    // 本地存入token
                    if (res.success) {
                      localStorage.setItem('access_token', res.result['token']);
                      that.getRole();
                    } else {
                      $.Jwarning(res.message);
                      setTimeout(function() {
                        window.location.href = "../login.html";
                      }, 2000)
                    }
                  },
                  error: function(err) {
                    console.log(JSON.stringify(err));
                  }
                });
              }
            }else{//当前处于单点登录
						  this.autoLogin(autoUsername);
            }
					},
					// 获取角色
					getRole() {
						let that = this;
						ajaxHttp({
							url: 'jeecg-boot/sys/role/queryRoleByUser',
							type: 'post',
							data: {},
							success: function(res) {
								// console.log(JSON.stringify(res));
								if (res.success) {
									res.result.forEach(item => {
										if (item.roleCode == "ProjectAdmin") { // 经营人员
											that.roleCode = item.roleCode;
											that.getStatistics();
										} else if (item.roleCode == "ProjectNodeViewRole") { // 业主
											that.roleCode = item.roleCode;
										} else if (item.roleCode == "ComplaintHandleRole") { // 投诉人员
											that.roleComplaint = true;
											that.getStatistics();
										} else if (item.roleCode == "AdjustHandleRole") { // 调整权限
											that.roleAdjust = true;
											that.getStatistics();
										} else if (item.roleCode == "LeaderRole") { // 领导
											that.roleCode = item.roleCode;
											that.getStatistics();
										} else if (item.roleCode == "DepartLeaderRole") { // 部门领导
											that.roleCode = item.roleCode;
											that.getStatistics();
										} else if (item.roleCode == "TeamLeader") { // 大组长
											that.roleCode = item.roleCode;
											that.getStatistics();
										}
									})
								} else {
									$.Jwarning(res.message)
								}
							}
						})
					},
				}
			})
		</script>
	</body>
</html>
